Meet JSON's functional half-brother.
If your business logic has a single-source-of-truth (SSOT) problem, JSOL may help.
I built JSOL because I didn't want to keep maintaining the same rules twice (once for the server, once again for the browser) on IPAX, a color science framework for accessible design systems. Every change meant updating both, testing both, and hoping they still agreed.
Did you know that something as simple as modulo can give you different results across languages? My LLM didn't. Turns out that 7.5 % 2 is 1.5 in JS… and 1 in PHP. And that's just one bug that slipped through code review.
Since most general-use languages today are somehow C-like, I wondered if there was some lingua franca we could use to declare business logic once, and include afterwards in our code with bit-for-bit parity.
That's how JSOL was born: a strict subset of JavaScript that transpiles to JavaScript, PHP, TypeScript and Python (with more targets planned), guaranteeing deterministic parity. Write the rule once, change it once, test it once.
Think JSON, but for business logic.
Is it worth your time?
The first question we developers ask about a new tool is: "Should I bother learning this?"
JSOL has strict syntax, zero syntactic sugar, and a learning curve. Writing it — even with an AI's help — will take you longer than writing native code you've already mastered. But JSOL's upfront cost can pay off in iterative maintenance.
The honest way to answer that question is with a model. So the first example below is exactly that: an adoption-economics model written in JSOL, running live in the REPL. And compiled to every target for inspection.
Play with the inputs: how many targets you maintain, how often your rules change, how many iterations until the upfront cost pays for itself. Add rows to evaluate different scenarios. And while you're at it, you're watching JSOL do what it was built to do.
(INPUT)
(OUTPUT)
Function: $bValidateIban
// @JSOL v0.2.91
/**
@description
Validates an IBAN (International Bank Account Number) using the ISO
13616 mod-97 checksum: move the first 4 characters to the end, convert
every letter to its numeric value (A=10, B=11, ... Z=35), and the
resulting numeric string must be congruent to 1 mod 97.
That numeric string routinely runs 30+ digits long, far past what a
64-bit float represents exactly (see digit-sum.jsol.js in 01-basics for
the same lesson). It is never cast to a number here: the mod-97 is
computed digit by digit instead, folding each new digit into a running
remainder as (remainder * 10 + digit) mod 97. That is mathematically
equivalent to computing the mod of the full number, but never needs a
variable large enough to hold it.
@param {string} $sIban - IBAN to validate, may contain spaces.
@returns {boolean} - True if $sIban passes the mod-97 checksum.
*/
/**
@contract
{
"cases": [
{ "$sIban": "GB29 NWBK 6016 1331 9268 19" },
{ "$sIban": "GB29 NWBK 6016 1331 9268 18" }
]
}
*/
const $bValidateIban = function($sIban) {
// Step 1: strip spaces, uppercase for consistent letter comparison.
const $iRawLen = Str.len($sIban);
let $sClean = "";
for (let $i = 0; $i < $iRawLen; $i = $i + 1) {
const $sChar = Str.sub($sIban, $i, 1);
if ($sChar !== " ") {
$sClean = $sClean + $sChar;
}
}
$sClean = Str.upper($sClean);
const $iLen = Str.len($sClean);
if ($iLen < 5) {
return false;
}
// Step 2: move the first 4 characters to the end.
const $sFirstFour = Str.sub($sClean, 0, 4);
const $sRest = Str.sub($sClean, 4, $iLen - 4);
const $sRearranged = $sRest + $sFirstFour;
// Step 3: walk the rearranged string, folding each character's numeric
// contribution into a running mod-97 remainder.
const $iRearrangedLen = Str.len($sRearranged);
let $qRemainder = 0;
for (let $i = 0; $i < $iRearrangedLen; $i = $i + 1) {
const $qCode = Str.char($sRearranged, $i);
if ($qCode >= 48 && $qCode <= 57) {
// '0'-'9': use the digit directly.
const $qDigit = $qCode - 48;
$qRemainder = ($qRemainder * 10 + $qDigit) % 97;
} else if ($qCode >= 65 && $qCode <= 90) {
// 'A'-'Z': letter value is 10-35, two digits, folded in as two
// separate steps.
const $qLetterValue = $qCode - 55;
const $qTens = Math.floor($qLetterValue / 10);
const $qUnits = $qLetterValue % 10;
$qRemainder = ($qRemainder * 10 + $qTens) % 97;
$qRemainder = ($qRemainder * 10 + $qUnits) % 97;
} else {
// Anything that isn't a digit or an uppercase letter means
// $sIban was never validly formatted to begin with.
return false;
}
}
return $qRemainder === 1;
};
// @JSOL v0.2.91
/**
@description
Validates an IBAN (International Bank Account Number) using the ISO
13616 mod-97 checksum: move the first 4 characters to the end, convert
every letter to its numeric value (A=10, B=11, ... Z=35), and the
resulting numeric string must be congruent to 1 mod 97.
That numeric string routinely runs 30+ digits long, far past what a
64-bit float represents exactly (see digit-sum.jsol.js in 01-basics for
the same lesson). It is never cast to a number here: the mod-97 is
computed digit by digit instead, folding each new digit into a running
remainder as (remainder * 10 + digit) mod 97. That is mathematically
equivalent to computing the mod of the full number, but never needs a
variable large enough to hold it.
@param {string} $sIban - IBAN to validate, may contain spaces.
@returns {boolean} - True if $sIban passes the mod-97 checksum.
*/
/**
@contract
{
"cases": [
{ "$sIban": "GB29 NWBK 6016 1331 9268 19" },
{ "$sIban": "GB29 NWBK 6016 1331 9268 18" }
]
}
*/
const $bValidateIban = function($sIban) {
// Step 1: strip spaces, uppercase for consistent letter comparison.
const $iRawLen = $sIban.length;
let $sClean = "";
for (let $i = 0; $i < $iRawLen; $i = $i + 1) {
const $sChar = $sIban.substring( $i, ( $i) + ( 1));
if ($sChar !== " ") {
$sClean = $sClean + $sChar;
}
}
$sClean = $sClean.toUpperCase();
const $iLen = $sClean.length;
if ($iLen < 5) {
return false;
}
// Step 2: move the first 4 characters to the end.
const $sFirstFour = $sClean.substring( 0, ( 0) + ( 4));
const $sRest = $sClean.substring( 4, ( 4) + ( $iLen - 4));
const $sRearranged = $sRest + $sFirstFour;
// Step 3: walk the rearranged string, folding each character's numeric
// contribution into a running mod-97 remainder.
const $iRearrangedLen = $sRearranged.length;
let $qRemainder = 0;
for (let $i = 0; $i < $iRearrangedLen; $i = $i + 1) {
const $qCode = $sRearranged.charCodeAt( $i);
if ($qCode >= 48 && $qCode <= 57) {
// '0'-'9': use the digit directly.
const $qDigit = $qCode - 48;
$qRemainder = ($qRemainder * 10 + $qDigit) % 97;
}
else if ($qCode >= 65 && $qCode <= 90) {
// 'A'-'Z': letter value is 10-35, two digits, folded in as two
// separate steps.
const $qLetterValue = $qCode - 55;
const $qTens = Math.floor($qLetterValue / 10);
const $qUnits = $qLetterValue % 10;
$qRemainder = ($qRemainder * 10 + $qTens) % 97;
$qRemainder = ($qRemainder * 10 + $qUnits) % 97;
}
else {
// Anything that isn't a digit or an uppercase letter means
// $sIban was never validly formatted to begin with.
return false;
}
}
return $qRemainder === 1;
};
window['$bValidateIban'] = $bValidateIban;
<?php
// @JSOL v0.2.91
/**
@description
Validates an IBAN (International Bank Account Number) using the ISO
13616 mod-97 checksum: move the first 4 characters to the end, convert
every letter to its numeric value (A=10, B=11, ... Z=35), and the
resulting numeric string must be congruent to 1 mod 97.
That numeric string routinely runs 30+ digits long, far past what a
64-bit float represents exactly (see digit-sum.jsol.js in 01-basics for
the same lesson). It is never cast to a number here: the mod-97 is
computed digit by digit instead, folding each new digit into a running
remainder as (remainder * 10 + digit) mod 97. That is mathematically
equivalent to computing the mod of the full number, but never needs a
variable large enough to hold it.
@param {string} $sIban - IBAN to validate, may contain spaces.
@returns {boolean} - True if $sIban passes the mod-97 checksum.
*/
/**
@contract
{
"cases": [
{ "$sIban": "GB29 NWBK 6016 1331 9268 19" },
{ "$sIban": "GB29 NWBK 6016 1331 9268 18" }
]
}
*/
$bValidateIban = function($sIban) {
// Step 1: strip spaces, uppercase for consistent letter comparison.
$iRawLen = mb_strlen($sIban, "UTF-8");
$sClean = "";
for ($i = 0; $i < $iRawLen; $i = $i + 1) {
$sChar = mb_substr($sIban, $i, 1, "UTF-8");
if ($sChar !== " ") {
$sClean = $sClean . $sChar;
}
}
$sClean = mb_strtoupper($sClean, "UTF-8");
$iLen = mb_strlen($sClean, "UTF-8");
if ($iLen < 5) {
return false;
}
// Step 2: move the first 4 characters to the end.
$sFirstFour = mb_substr($sClean, 0, 4, "UTF-8");
$sRest = mb_substr($sClean, 4, $iLen - 4, "UTF-8");
$sRearranged = $sRest . $sFirstFour;
// Step 3: walk the rearranged string, folding each character's numeric
// contribution into a running mod-97 remainder.
$iRearrangedLen = mb_strlen($sRearranged, "UTF-8");
$qRemainder = 0;
for ($i = 0; $i < $iRearrangedLen; $i = $i + 1) {
$qCode = mb_ord(mb_substr($sRearranged, $i, 1, "UTF-8"));
if ($qCode >= 48 && $qCode <= 57) {
// '0'-'9': use the digit directly.
$qDigit = $qCode - 48;
$qRemainder = ($qRemainder * 10 + $qDigit) % 97;
}
else if ($qCode >= 65 && $qCode <= 90) {
// 'A'-'Z': letter value is 10-35, two digits, folded in as two
// separate steps.
$qLetterValue = $qCode - 55;
$qTens = floor($qLetterValue / 10);
$qUnits = $qLetterValue % 10;
$qRemainder = ($qRemainder * 10 + $qTens) % 97;
$qRemainder = ($qRemainder * 10 + $qUnits) % 97;
}
else {
// Anything that isn't a digit or an uppercase letter means
// $sIban was never validly formatted to begin with.
return false;
}
}
return $qRemainder === 1;
};
declare var JSOL: any;
declare var Rgx: any;
// @JSOL v0.2.91
/**
@description
Validates an IBAN (International Bank Account Number) using the ISO
13616 mod-97 checksum: move the first 4 characters to the end, convert
every letter to its numeric value (A=10, B=11, ... Z=35), and the
resulting numeric string must be congruent to 1 mod 97.
That numeric string routinely runs 30+ digits long, far past what a
64-bit float represents exactly (see digit-sum.jsol.js in 01-basics for
the same lesson). It is never cast to a number here: the mod-97 is
computed digit by digit instead, folding each new digit into a running
remainder as (remainder * 10 + digit) mod 97. That is mathematically
equivalent to computing the mod of the full number, but never needs a
variable large enough to hold it.
@param {string} $sIban - IBAN to validate, may contain spaces.
@returns {boolean} - True if $sIban passes the mod-97 checksum.
*/
/**
@contract
{
"cases": [
{ "$sIban": "GB29 NWBK 6016 1331 9268 19" },
{ "$sIban": "GB29 NWBK 6016 1331 9268 18" }
]
}
*/
const $bValidateIban = function($sIban: any): boolean {
// Step 1: strip spaces, uppercase for consistent letter comparison.
const $iRawLen: number = $sIban.length;
let $sClean: string = "";
for (let $i = 0; $i < $iRawLen; $i = $i + 1) {
const $sChar: string = $sIban.substring( $i, ( $i) + ( 1));
if ($sChar !== " ") {
$sClean = $sClean + $sChar;
}
}
$sClean = $sClean.toUpperCase();
const $iLen: number = $sClean.length;
if ($iLen < 5) {
return false;
}
// Step 2: move the first 4 characters to the end.
const $sFirstFour: string = $sClean.substring( 0, ( 0) + ( 4));
const $sRest: string = $sClean.substring( 4, ( 4) + ( $iLen - 4));
const $sRearranged: string = $sRest + $sFirstFour;
// Step 3: walk the rearranged string, folding each character's numeric
// contribution into a running mod-97 remainder.
const $iRearrangedLen: number = $sRearranged.length;
let $qRemainder: number = 0;
for (let $i = 0; $i < $iRearrangedLen; $i = $i + 1) {
const $qCode: number = $sRearranged.charCodeAt( $i);
if ($qCode >= 48 && $qCode <= 57) {
// '0'-'9': use the digit directly.
const $qDigit: number = $qCode - 48;
$qRemainder = ($qRemainder * 10 + $qDigit) % 97;
}
else if ($qCode >= 65 && $qCode <= 90) {
// 'A'-'Z': letter value is 10-35, two digits, folded in as two
// separate steps.
const $qLetterValue: number = $qCode - 55;
const $qTens: number = Math.floor($qLetterValue / 10);
const $qUnits: number = $qLetterValue % 10;
$qRemainder = ($qRemainder * 10 + $qTens) % 97;
$qRemainder = ($qRemainder * 10 + $qUnits) % 97;
}
else {
// Anything that isn't a digit or an uppercase letter means
// $sIban was never validly formatted to begin with.
return false;
}
}
return $qRemainder === 1;
};
import math
from jsol_core import JSOL
# @JSOL v0.2.91
#*
# @description
# Validates an IBAN (International Bank Account Number) using the ISO
# 13616 mod-97 checksum: move the first 4 characters to the end, convert
# every letter to its numeric value (A=10, B=11, ... Z=35), and the
# resulting numeric string must be congruent to 1 mod 97.
# That numeric string routinely runs 30+ digits long, far past what a
# 64-bit float represents exactly (see digit-sum.jsol.js in 01-basics for
# the same lesson). It is never cast to a number here: the mod-97 is
# computed digit by digit instead, folding each new digit into a running
# remainder as (remainder * 10 + digit) mod 97. That is mathematically
# equivalent to computing the mod of the full number, but never needs a
# variable large enough to hold it.
#
#@param {string} $sIban - IBAN to validate, may contain spaces.
#@returns {boolean} - True if $sIban passes the mod-97 checksum.
#
#*
# @contract
# {
# "cases": [
# { "$sIban": "GB29 NWBK 6016 1331 9268 19" },
# { "$sIban": "GB29 NWBK 6016 1331 9268 18" }
# ]
# }
#
def bValidateIban(sIban):
# Step 1: strip spaces, uppercase for consistent letter comparison.
iRawLen = len(sIban);
sClean = "";
i = 0;
while i < iRawLen:
sChar = sIban[( i):( i)+( 1)];
if sChar != " ":
sClean = sClean + sChar;
i = i + 1;
sClean = sClean.upper();
iLen = len(sClean);
if iLen < 5:
return False;
# Step 2: move the first 4 characters to the end.
sFirstFour = sClean[( 0):( 0)+( 4)];
sRest = sClean[( 4):( 4)+( iLen - 4)];
sRearranged = sRest + sFirstFour;
# Step 3: walk the rearranged string, folding each character's numeric
# contribution into a running mod-97 remainder.
iRearrangedLen = len(sRearranged);
qRemainder = 0;
i = 0;
while i < iRearrangedLen:
qCode = ord(sRearranged[ i]);
if qCode >= 48 and qCode <= 57:
# '0'-'9': use the digit directly.
qDigit = qCode - 48;
qRemainder = (qRemainder * 10 + qDigit) % 97;
elif qCode >= 65 and qCode <= 90:
# 'A'-'Z': letter value is 10-35, two digits, folded in as two
# separate steps.
qLetterValue = qCode - 55;
qTens = math.floor(qLetterValue / 10);
qUnits = qLetterValue % 10;
qRemainder = (qRemainder * 10 + qTens) % 97;
qRemainder = (qRemainder * 10 + qUnits) % 97;
else:
# Anything that isn't a digit or an uppercase letter means
# $sIban was never validly formatted to begin with.
return False;
i = i + 1;
return qRemainder == 1;
Each example started as a test.
The language and compiler improved because of what these examples demanded. The CLRS examples are here for the same reason: if JSOL aims to be a language someone can read rather than just compile, it has to survive contact with computer science, not just invoicing.
Strict Validation
Finance & Rules
Computer Science
What JSOL is NOT
JSOL is not a full-stack framework, and it's not a general-purpose language. It is an isolated, pure, synchronous calculator.
It doesn't touch the DOM, it doesn't make network requests (no fetch or Async), and it doesn't talk to databases.
Every alternative to JSOL (like Haxe or WebAssembly) buys generality or performance at the cost of requiring a toolchain. JSOL buys zero-toolchain portability by aggressively restricting what you can write.
The Honest Tradeoffs (Where JSOL is worse)
JSOL costs more to write than a native implementation. These are the engine-level restrictions you accept when using it:
| Feature | Native JS / PHP | JSOL | Why it was stripped |
|---|---|---|---|
| Developer Speed | Fast (Syntactic sugar, functional methods) | Slower (Spartan syntax, mandatory imperative loops) | Functional arrays and sugar don't map 1:1 across engines without AST pipelines. |
| Control Flow | Async, Promises, Threads | Strictly Synchronous (Single-thread blocking) | Async control flow has no shared syntax between JS and PHP. |
| State & OOP | Classes, this, Prototypes |
Flat Dicts & Primitives (Higher GC pressure) | Classes diverge wildly. Forbidding them guarantees O(1) property access but forces state copying for large loops. |
| Text Parsing | Native Regex (PCRE / V8) | Procedural loops only (No native regex) | Regex engines differ. Complex patterns can cause ReDoS in one engine but not another. |
Design Pillars
Four principles shape every rule in the specification.
1. Clarity
A JSOL algorithm has to be readable by the person who owns the business logic, not just by a compiler.
This is also why JSOL doesn't standardize how you structure code (nested functions vs. flat scope, for instance) — that's implementation shape, not business logic.
2. Portability
The same source runs correctly on every proven target.
This is where Deterministic Parity comes from: given identical inputs, every target's output has to match, bit for bit.
3. Performance
The compiled output should be no heavier and no slower than it has to be.
This is where Zero Dead Code comes from: nothing gets shipped that a given file doesn't actually use.
4. Developer Experience
Writing, compiling, and debugging JSOL should be as frictionless as the constraints allow.
This is where the AST-free compiler pipeline and Zero Runtime Dependencies come from.
This is an open problem, not a finished product
JSOL works today for JavaScript, PHP, TypeScript and Python. The compiler is self-hosting (i.e., it compiles itself) and the fixed-point convergence tests prove that the output is stable across generations and hosts. But the really interesting work is what comes next.
The project's real bet is that the same approach can extend to other targets. TypeScript, Go, C#, Python, Rust, C: each one is a separate compiler backend, and each one teaches you something different about what "portable business logic" actually requires.
If you're a CS educator or student, EXTENDING.md lays out the feasibility matrix, the JSOL-C leverage effect, and the specific compiler design problems involved.
Fork it. Break it. Build a target. The compiler architecture is deliberately modular: adding a language means writing one compiler file, not rewriting the core.